<?php

use Doraemon\pockets\constInterface\EsDbFieldsMap;
use Doraemon\service\Event\Es\EsOperateCounter;
use Doraemon\tools\Log;

class EsOperateContentCounterAction extends ActionPlugin
{
    const IS_TRACING = true;

    /**
     * @throws Exception
     */
    public function main()
    {
        Log::info('Es操作内容计数器接收到的订阅消息', $this->messageBody);

        if (!$this->messageBody['table']) throw new \Exception('未获取到数据表');
        if (!$this->messageBody['data']) throw new \Exception('未接收到数据');

        if (in_array($this->messageBody['table'], EsDbFieldsMap::CONTENT_COUNTER_TABLE_MAP)) EsOperateCounter::operateContentEsCounter($this->messageBody['data']);

        $this->setSuccess();
    }
}